var numArr = [0];
localStorage.setItem("numArr",numArr);
var $;
var element;
layui.use(['jquery','element'],function () {
    $ = layui.$;
    element = layui.element;

    element.on('tab(head_tabs)', function(data){
        var lay_id=$(this).attr("lay-id");
        var nav_tree=$(".layui-nav-tree");
        //移除其他选中
        nav_tree.find("a[menu_id]").parent().removeClass("layui-this");
        //选中点击的
        var kv="a[menu_id='"+lay_id+"']";
        nav_tree.find(kv).parent().addClass("layui-this")
    });
});

var active = {
    tabAdd: function(){
        //新增一个Tab项
        var menu_url=$(this).attr('menu_url');
        var menu_name=$(this).attr('menu_name');
        var menu_id=$(this).attr('menu_id');
        //先判断是否已经有了tab
        var arrayObj = new Array();　//创建一个数组
        $(".layui-tab-title").find('li').each(function() {
            var y = $(this).attr("lay-id");
            arrayObj.push(y);
        });
        var have=$.inArray(menu_id, arrayObj);
        if (have>=0) {
            //tab已有标签
            element.tabChange('head_tabs', menu_id); //切换到当前点击的页面
        } else{
            //没有相同tab
            element.tabAdd('head_tabs', {
                title:menu_name
                ,content: '<iframe class="ifra" style="width: 100%" onload="FrameWH()" scrolling="no" src='+menu_url+' ></iframe>'
                ,id: menu_id
            });
            element.tabChange('head_tabs', menu_id); //切换到当前点击的页面
        }
    }
};

function hitEvent(obj){
    var type="tabAdd";
    var othis = $(obj);
    active[type] ? active[type].call(obj, othis) : '';
};

$.ajax({
    url:'/login/getUser',
    dataType:'json',
    success:function (data) {
        data = data.data;
        localStorage.setItem('user', JSON.stringify(data));
        $('#headerImage').attr("src",data.acatarUrl);
        $('.userName').text(data.account);
        $("#loginDept").text(data.deptName);
        getLoginUser(data.userId);
    }
});

//导航栏
$.ajax({
    url:'/navigationBar/getNavigationBar',
    dataType:'json',
    success:function (data) {

        layui.use(['jquery','element'],function () {
            $ = layui.$;
            element = layui.element;

            var nav = data.data;
            var html = '';
            html +='<ul class="layui-nav layui-nav-tree layui-nav-side" lay-filter="nav-tree">';
            $.each(nav,function (i,item) {
                if(item.menuId == 1){
                    html = html+'<li class="layui-nav-item layui-nav-itemed ">';
                }else{
                    html = html+'<li class="layui-nav-item">';
                }
                html += '<a href="javascript:;">'+item.icon+item.menuName+'</a>';
                if(item.children.length > 0){
                    html += '<dl class="layui-nav-child">';
                    $.each(item.children,function (j,children) {
                        if(children.menuId == 2){
                            html+='<dd class="layui-nav-itemed">'
                        }else{
                            html+='<dd>'
                        }
                        html += '<a href="javascript:;">'+children.menuName+'</a>';
                        if(children.children.length > 0){
                            html += '<dl class="layui-nav-child">';
                            $.each(children.children,function (k,childrenItem) {
                                if(childrenItem.menuId == 3){
                                    html += '<dd class="layui-this">'+
                                        '<a href="javascript:;" id="menId" menu_name="'+childrenItem.menuName+'" menu_id="'+childrenItem.menuId+'" onclick="hitEvent(this)" class="submenu" menu_url="'+childrenItem.url+'" >'+childrenItem.menuName+'</a>' +
                                        '</dd>';
                                }else{
                                    html += '<dd>'+
                                        '<a href="javascript:;" menu_name="'+childrenItem.menuName+'" menu_id="'+childrenItem.menuId+'" onclick="hitEvent(this)" class="submenu" menu_url="'+childrenItem.url+'" >'+childrenItem.menuName+'</a>' +
                                        '</dd>';
                                }
                            });
                            html+= '</dl>';
                        }
                    });
                    html+= '</dl>' ;
                };
                html+= '</li>';
            });
            html+='</ul>';
            $(".division").append(html);
            element.init();

            //点击导航栏关闭其他导航栏
            $(".layui-nav-tree li").on("click","a",function (e) {
                if($(this).parent("li").hasClass("closeDao")){
                    $(this).parent("li").removeClass("layui-nav-itemed");
                    $(this).parent("li").removeClass("closeDao");
                }else{
                    $(this).parent("li").addClass("layui-nav-itemed").siblings("li").removeClass("layui-nav-itemed");
                    $(this).parent("li").addClass("closeDao").siblings("li").removeClass("closeDao");
                }
                $(this).siblings("dl").children("dd").removeClass("closeDao").siblings("dd").removeClass("closeDao");
                $(this).siblings("dl").children("dd").removeClass("layui-nav-itemed").siblings("dd").removeClass("layui-nav-itemed");
            });

            //点击导航栏关闭其他导航栏(内部)
            $(".layui-nav-tree li dl dd").on("click","a",function (e) {
                if($(this).parent("dd").hasClass("closeDao")){
                    $(this).parent("dd").removeClass("layui-nav-itemed");
                    $(this).parent("dd").removeClass("closeDao");
                }else{
                    $(this).parent("dd").addClass("layui-nav-itemed").siblings("dd").removeClass("layui-nav-itemed");
                    $(this).parent("dd").addClass("closeDao").siblings("dd").removeClass("closeDao");
                }
            });
            $('#menId').click();



            $("#hitLi").on("click","li",function () {
                var i = $(this).attr("lay-id");
                var arr = localStorage.getItem("numArr");
                i = "" + i + "";
                numArr = arr.split(",");
                if (i != numArr[numArr.length -1]){
                    numArr.push(i);
                }
                localStorage.setItem("numArr",numArr);
            });

            var accountHref;
            var h;
            var systemHomeHref;
            var systemHomeTitle;

            $("dd .submenu").each(function () {
                if ($(this).text() == "账户设置"){
                    accountHref = $(this).attr("menu_url");
                    h = $(this).text();
                    return;
                }
                if ($(this).text() == "首页"){
                    systemHomeHref = $(this).attr("menu_url");
                    systemHomeTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "微圈列表"){
                    microCircleListHref = $(this).attr("menu_url");
                    microCircleListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "商品列表"){
                    commodityListHref = $(this).attr("menu_url");
                    commodityListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "用户列表"){
                    userListHref = $(this).attr("menu_url");
                    userListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "轮播图列表"){
                    lunImgsListHref = $(this).attr("menu_url");
                    lunImgsListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "课程列表"){
                    classListHref = $(this).attr("menu_url");
                    classListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "后台人员列表"){
                    behindUserListHref = $(this).attr("menu_url");
                    behindUserListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "订单统计"){
                    transactionImgsListHref = $(this).attr("menu_url");
                    transactionImgsListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "部门管理"){
                    departmentListHref = $(this).attr("menu_url");
                    departmentListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "优惠券列表"){
                    couponListHref = $(this).attr("menu_url");
                    couponListTitle = $(this).text();
                    return;
                }
                if ($(this).text() == "课程订单列表"){
                    courseOrderListHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "商品订单列表"){
                    commodityOrderListHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "申请退订列表"){
                    unsubscribeListHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "课程审核列表"){
                    curriculumToExamineHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "商品审核列表"){
                    commodityToExamineHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "微圈审核列表"){
                    microCircleToExamineHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "微圈评论"){
                    microCircleCommentHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "课程评论"){
                    curriculumCommentHref = $(this).attr("menu_url");
                    return;
                }
                if ($(this).text() == "审核日志"){
                    toExamineLogHref = $(this).attr("menu_url");
                    return;
                }
            });

            $("#accountHref").attr("href",accountHref);
            $("#systemHome").attr("href",systemHomeHref);
            $("#microCircleListHref").attr("href",microCircleListHref);
            $("#commodityListHref").attr("href",commodityListHref);
            $("#userListHref").attr("href",userListHref);
            $("#lunImgsListHref").attr("href",lunImgsListHref);
            $("#classListHref").attr("href",classListHref);
            $("#behindUserListHref").attr("href",behindUserListHref);
            $("#transactionImgsListHref").attr("href",transactionImgsListHref);
            $("#departmentListHref").attr("href",departmentListHref);
            $("#couponListHref").attr("href",couponListHref);
            $("#courseOrderListHref").attr("href",courseOrderListHref);
            $("#commodityOrderListHref").attr("href",commodityOrderListHref);
            $("#unsubscribeListHref").attr("href",unsubscribeListHref);
            $("#curriculumToExamineHref").attr("href",curriculumToExamineHref);
            $("#commodityToExamineHref").attr("href",commodityToExamineHref);
            $("#microCircleToExamineHref").attr("href",microCircleToExamineHref);
            $("#microCircleCommentHref").attr("href",microCircleCommentHref);
            $("#curriculumCommentHref").attr("href",curriculumCommentHref);
            $("#toExamineLogHref").attr("href",toExamineLogHref);


            //获取选项卡删除事件
            $(".layui-tab").on("click",function(e){
                if($(e.target).is(".layui-tab-close")){
                    $(".rightmenu").css("display","none");
                }
            });

            //解决删除中间选项卡不能返回的bug
            $(".layui-tab").on("mouseover",function(e){
                if($(e.target).is(".layui-tab-close")){
                    var indexNum = $(e.target).parent("li").attr("lay-id");
                    var jq = $(e.target);
                    indexNum = "" + indexNum + "";

                    var arr = localStorage.getItem("numArr");
                    numArr = arr.split(",");

                    jq.on("click",function () {
                        //将满足指定条件的数组元素存放到新数组并返回新数组
                        var newNumArr = numArr.filter(function (item) {
                            if (item != indexNum ){
                                return item;
                            }
                        });
                        var newArr = [];
                        //
                        for (var i = 0; i < newNumArr.length; i++) {
                            if (newNumArr[i] != newNumArr[i + 1]) {
                                newArr.push(newNumArr[i]);
                            }
                        }
                        numArr = newArr;

                        localStorage.setItem("numArr",numArr);
                        return true;
                    });
                }
            });

        });
    }
});


function FrameWH() {
    //var iframeHeight = $(".ifra").contents().find("body").height();
    var iframeHeight = $(window).height()+280;

    $(".layui-tab-item").css("height","100%");
    $("iframe").css("height", iframeHeight + "px");
}


//退出登录
function loginOut() {
    $.ajax({
        type:"post",
        url:"/login/loginOut",
        data:{},
        dataType:"json",
        success:function (data) {
            if(data){
                localStorage.removeItem("user")
                //退出到登录页面
                location.href="/login/login.html";
            }
        }
    })
    // return false;
};

//根据id查询登陆日志
function getLoginUser(id) {
    $.ajax({
        url:'/navigationBar/getLoginUserrById',
        method:'post',
        data:{"id": id},
        dataType:'json',
        success: function (data) {
            if (data.data[0] != null){
                $("#nowLoginTime").text(data.data[0].loginDate);
                if (data.data[1] != null){
                    $("#oldLoginTime").text(data.data[1].loginDate);
                }
                $("#loginAddress").text(data.data[0].loginAddress);
                $("#loginIp").text(data.data[0].loginIp);
            }
        }
    })
};

//查询提示信息
getOrderQuantityStatus();
function getOrderQuantityStatus(id) {
    var orderNum = 0;
    //订单提示
    $.ajax({
        url: "/navigationBar/getOrderQuantityStatus",
        methods: "post",
        data: {"id": id},
        dataType: "json",
        success: function (data) {
            $("#span1").text(data.data.videoNoNums);
            orderNum += data.data.videoNoNums;
            $("#span2").text(data.data.productNoNums);
            orderNum += data.data.productNoNums;
            $("#span3").text(data.data.microCircleNoNums);
            orderNum += data.data.microCircleNoNums;
            $("#span4").text(data.data.courseOrder);
            orderNum += data.data.courseOrder;
            $("#span5").text(data.data.productOrder);
            orderNum += data.data.productOrder;
            $("#span6").text(data.data.returnRequest);
            orderNum += data.data.returnRequest;
            //广告位提示
            $.ajax({
                url:'/navigationBar/getAllCarousel',
                methods: "post",
                dataType:'json',
                success:function (data) {
                    var nowDate = new Date().getTime();
                    var n = 0;
                    data.data.forEach(function (ele) {
                        //将日期转换为毫秒值
                        if (ele.expireDate != null){
                            var expireDate = new Date(ele.expireDate.replace(new RegExp('-', 'gm'), '/')).getTime()
                            if ((expireDate - nowDate) <= 172800000 && (expireDate - nowDate) > 0) {
                                n += 1;
                            }
                        }
                    });
                    $("#span7").text(n);
                    orderNum += n;
                    $(".layui-badge").text(orderNum);
                    changeFontColor();
                }
            });
        }
    });
};



//头部导航栏菜单消息鼠标悬停改变颜色
function changeFontColor() {
    $(".menu a,#notice-div a").on("mouseover",function () {
        $(this).css("color","#0DAB9E");
        $(this).find(".count_left").css("color","#0DAB9E");
        $(this).find(".fColor").css("color","#0DAB9E");
    });
    $(".menu a,#notice-div a").on("mouseout",function () {
        $(this).css("color","#000");
        $(this).find(".count_left").css("color","#000");
        $(this).find(".fColor").css("color","red");
    });
}

//头部导航栏点击跳转商品订单列表
function jumpCourseOrderList() {
    var title = "课程订单列表";
    var href = $("#courseOrderListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转商品订单列表
function jumpCommodityOrderList() {
    var title = "商品订单列表";
    var href = $("#commodityOrderListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转申请退订列表
function jumpUnsubscribeListHref() {
    var title = "申请退订列表";
    var href = $("#unsubscribeListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转课程审核列表
function jumpCurriculumToExamineHref() {
    var title = "课程审核列表";
    var href = $("#curriculumToExamineHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转商品审核列表
function jumpCommodityToExamineHref() {
    var title = "商品审核列表";
    var href = $("#commodityToExamineHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}


//头部导航栏点击跳转微圈审核列表
function jumpMicroCircleToExamineHref() {
    var title = "微圈审核列表";
    var href = $("#microCircleToExamineHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转微圈评论
function jumpMicroCircleCommentHref() {
    var title = "微圈评论";
    var href = $("#microCircleCommentHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转课程评论
function jumpCurriculumCommentHref() {
    var title = "课程评论";
    var href = $("#curriculumCommentHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转审核日志
function jumpToExamineLogHref() {
    var title = "审核日志";
    var href = $("#toExamineLogHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转账户设置
function jumpAccount() {
    var title = $("#accountSettings").text();
    var href = $("#accountHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转商品列表
function jumpCommodityList() {
    var title = $("#commodityList").text();
    var href = $("#commodityListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转微圈列表
function jumpMicroCircleList() {
    var title = $("#microCircleList").text();
    var href = $("#microCircleListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}


//头部常用菜单跳转用户列表
function jumpUserList() {
    var title = $("#userList").text();
    var href = $("#userListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}
//头部常用菜单跳转轮播图列表
function jumpLunImgsList() {
    var title = $("#lunImgsList").text();
    var href = $("#lunImgsListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转课程列表
function jumpClassList() {
    var title = $("#classList").text();
    var href = $("#classListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转后台人员列表
function jumpBehindUserList() {
    var title = $("#behindUserList").text();
    var href = $("#behindUserListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转订单统计
function jumpTransactionImgsList() {
    var title = $("#transactionImgsList").text();
    var href = $("#transactionImgsListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转部门管理
function jumpDepartmentList() {
    var title = $("#departmentList").text();
    var href = $("#departmentListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部常用菜单跳转优惠券列表
function jumpCouponList() {
    var title = $("#couponList").text();
    var href = $("#couponListHref").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//头部导航栏点击跳转首页
function jumpSystemHome() {
    var title = $("#systemHomeHit").attr("title");
    var href = $("#systemHome").attr("href");
    var len =  $('.layui-tab-title li').length;
    publicCode(title,href,len);
}

//简化后的--跳转--最终
function jump(flag) {
    var title,
        href,
        len;
    $("dd .submenu").each(function () {
        if ($(this).text() == flag){
            href = $(this).attr("menu_url");
            title = $(this).text();
            len =  $('.layui-tab-title li').length;
            return;
        }
    });
    publicCode(title,href,len);
}

//导航栏公共代码1
function publicCode(title,href,len) {
    var menuArr = [];
    $("#hitLi li").each(function () {
        menuArr.push($(this).text());
    });
    $("dd .submenu").each(function () {
        if ($(this).text() == title) {
            len = $(this).attr("menu_id");
            if (menuArr.indexOf(title) == -1){
                element.tabAdd('head_tabs',{
                    title: title,
                    content: '<iframe id="iframe'+ len + '" style="width: 100%" onload="FrameWH()" scrolling="no" frameborder="0" src="'+href+'"  class="iframe"></iframe>',
                    id: len
                })
                //跳转添加选项卡页面
                element.tabChange('head_tabs',len);
                var arr = localStorage.getItem("numArr");
                len = "" + len + "";
                numArr = arr.split(",");
                numArr.push(len);
                localStorage.setItem("numArr",numArr);
            }else {
                //跳转到点击选项卡页面
                var i = menuArr.indexOf(title);
                i = parseInt($(".layui-tab-title li").eq(i).attr("lay-id"));
                element.tabChange('head_tabs',i);
                var arr = localStorage.getItem("numArr");
                i = "" + i + "";
                numArr = arr.split(",");
                if (i != numArr[numArr.length -1]){
                    numArr.push(i);
                }
                localStorage.setItem("numArr",numArr);
            }
        }
    });
}

//导航栏公共代码2
function publicCode2(title,href,len) {
    var menuArr = [];
    $("#hitLi li").each(function () {
        menuArr.push($(this).text());
    });
    $("dd .submenu").each(function () {
        if ($(this).text() == title) {
            len = $(this).attr("menu_id");
            if (menuArr.indexOf(title) == -1){
                element.tabAdd('head_tabs',{
                    title: title,
                    content: '<iframe id="iframe'+ len + '" style="width: 100%" onload="FrameWH()" scrolling="no" frameborder="0" src="'+href+'"  class="iframe"></iframe>',
                    id:len
                })
                //跳转添加选项卡页面
                element.tabChange('head_tabs',len);
                var arr = localStorage.getItem("numArr");
                len = "" + len + "";
                numArr = arr.split(",");
                numArr.push(len);
                localStorage.setItem("numArr",numArr);
            }else {
                //跳转到点击选项卡页面
                var i = menuArr.indexOf(title);
                i = parseInt($(".layui-tab-title li").eq(i).attr("lay-id"));
                element.tabChange('head_tabs',i);
                //！！！！！！！！完成添加操作后跳转到对应列表并刷新该列表
                window.frames[i].location.reload();
                var arr = localStorage.getItem("numArr");
                i = "" + i + "";
                numArr = arr.split(",");
                if (i != numArr[numArr.length -1]){
                    numArr.push(i);
                }
                localStorage.setItem("numArr",numArr);
            }
        }
    });
}
rightClick();

//右键选项卡删除当前、其他、所有右键选项卡
function rightClick() {
    $("#hitLi").on("contextmenu","li",function (e) {
        //阻止浏览器默认右键操作
        e.preventDefault();
        $(".rightmenu").css("display","inline");
        index = $(this).attr("lay-id");
        element.tabChange('head_tabs',index);
        var top = $("#hitLi .layui-this").position().top;
        var left = $("#hitLi .layui-this").position().left;
        top += 50;
        left += 20;
        $(".rightmenu").css('position','absolute');
        $(".rightmenu").css('top',top);
        $(".rightmenu").css('left',left);
    });

    $("#hitLi li").on("click",function () {
        $(".rightmenu").css("display","none");
    });

    $(".rightmenu").on("click","li",function () {
        if ($(this).attr("data-type") == "closeNow") { //关闭当前
            if (index != 0){
                element.tabDelete('head_tabs',index);
                $(".rightmenu").css("display","none");
            }
            //$("#hitLi ").prop("lay-id","0");
        }
        if ($(this).attr("data-type") == "closeOthers") { //关闭其他
            var tabtitle = $(".layui-tab-title li");
            $.each(tabtitle, function (i) {
                if ($(this).attr("lay-id") != index && $(this).attr("lay-id") != 0) {
                    element.tabDelete('head_tabs',$(this).attr("lay-id"));
                    $(".rightmenu").css("display","none");
                }
            })
            //$("#hitLi ").prop("lay-id","0");
        }
        if ($(this).attr("data-type") == "closeAll") { //关闭所有
            var tabtitle = $(".layui-tab-title li");
            $.each(tabtitle, function (i) {
                if ($(this).attr("lay-id") != 0) {
                    element.tabDelete('head_tabs',$(this).attr("lay-id"));
                    $(".rightmenu").css("display","none");
                }
            })
        }
    });
}

$("body").on("click",function () {
    $(".rightmenu").css("display","none");
})

//默认展开系统首页
function loading() {
    $(".layui-nav-tree li a").each(function () {
        if ($(this).text() == "系统首页"){
            $(this).parent("li").addClass("layui-nav-itemed").siblings("li").removeClass("layui-nav-itemed");
            $(this).parent("li").addClass("closeDao").siblings("li").removeClass("closeDao");
            $(this).siblings("dl").children("dd").addClass("layui-nav-itemed").siblings("dd").removeClass("layui-nav-itemed");
            $(this).siblings("dl").children("dd").addClass("closeDao").siblings("dd").removeClass("closeDao");
            $(this).siblings('dl').children('dd').children('dl').children('dd').children('a').each(function (i,item) {
                if ($(this).text() == "首页"){
                    $(this).parent().addClass('layui-this');
                }
            })
        }

    });
}

//完成添加操作后跳转到对应列表
function quickEntry(){
    var quickEntry = $('#quickEntry').val();
    if (quickEntry == "轮播图列表"){
        var href = $("#lunImgsListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }else if (quickEntry == "商品列表"){
        var href = $("#commodityListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }else if (quickEntry == "用户列表"){
        var href = $("#userListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }else if (quickEntry == "课程列表"){
        var href = $("#classListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }else if (quickEntry == "优惠券列表"){
        var href = $("#couponListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }else if (quickEntry == "后台人员列表"){
        var href = $("#behindUserListHref").attr("href");
        var len =  $('.layui-tab-title li').length;
        publicCode2(quickEntry,href,len);
    }
    $('.submenu').each(function () {
        if($(this).text() == quickEntry){
            $(this).click();
        }
    })
}